﻿@model FollowPeers.Models.Message

@{
    ViewBag.Title = "New Reply";
    FollowPeers.Models.FollowPeersDBEntities followPeersDB = new FollowPeers.Models.FollowPeersDBEntities();
    string name = Membership.GetUser().UserName;
    FollowPeers.Models.UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);

    ViewBag.Receiver = Request.Params["Receiver"];

    ViewBag.Subject = Request.Params["Subject"];
    
}

@Html.Partial("_Header")

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
        <script src=@Url.Content("~/Scripts/jquery.bgiframe.js") type="text/javascript"></script>
        <script src=@Url.Content("~/Scripts/jquery.mcdropdown.js") type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="../../Content/css/jquery.mcdropdown.css" />

<div class="container" id="main">
    <div class="row">
    @Html.Partial("_MessageSideBar")
    <div class="span7" style="margin-left:10px">
        <h2>Reply</h2>
         @using (Html.BeginForm("Reply", "Message"))
         {
                 @Html.ValidationSummary(true)
                        @*
                        <input type="hidden" name="Sender" value="@ViewBag.Reciever" />
                        <input type="hidden" name="Receiver" value="@ViewBag.Sender" />
                        <input type="hidden" name="Subject" value="@ViewBag.Subject" /> *@
                        
                             <div class="editor-label" >
                            @Html.LabelFor(Model => Model.Reciever, "Send To")
                        </div>
                        <div class="editor-field">
                           @Html.TextBoxFor(Model => Model.Reciever, new { @Value= ViewBag.Receiver })
                           @Html.ValidationMessageFor(Model => Model.Reciever)
                        </div>
                        <div class="editor-label">
                            @Html.LabelFor(Model => Model.Subject, "Subject")
                        </div>
                        <div class="editor-field">
                            @Html.TextBoxFor(Model => Model.Subject, new { @Value = ViewBag.Subject })
                            
                            @Html.ValidationMessageFor(Model => Model.Subject)
                        </div>
                                                 
                        <fieldset>
                            <legend>@Html.LabelFor(m => Model.MessageBody, "Reply")</legend>
                            <div class="editor-field">
                                @Html.TextAreaFor(m => Model.MessageBody)
                            </div>
                            <input type="submit" value="Send" />
                        </fieldset>
                        
                        
         }

        <div>
            @Html.ActionLink("Back to Inbox", "Index")
        </div>
        </div>
    </div>
</div>




@Html.Partial("_Footer")

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
       
       $("#Message-Receiver").autocomplete({
            
            source: function (request,response){
                    $.ajax({
                        url: "/Profile/FindUserNames", type: "post", dataType: "json",
                        data: { searchText: request.term, maxResults: 10 },
                        success: function (data) {
				                    response($.map(data, function (item) { 
                                                return { label: item.UserName, value: item.UserName, id: item.UserProfileId }
				                            }))
                                }
                    })
            }
        });
    });
</script>